﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.missions {
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class PerformTaskCommand extends Command {

        public var event:InfoEvent;
        private var task:TaskVO;

        override public function execute():void{
            this.task = (this.event.info as TaskVO);
            this.sendTaskRequest();
        }
        private function onResult(_arg1:ResultVO):void{
            var _local2:Object;
            if (_arg1.success){
                _local2 = _arg1.data.perform_task;
                this.updateChanges(_local2);
            };
        }
        private function sendTaskRequest():void{
            var _local1:Object = {taskType:GameConstants.SEND_MAYOR, itemType:this.task.type, onResult:this.onResult, numActions:this.task.required};
            var _local2:Array = [new RequestVO("perform_task", {id:this.event.id})];
            var _local3:TaskRequestEvent = new TaskRequestEvent(EventConstants.SEND_TASK_REQUEST, _local2, _local1);
            dispatch(_local3);
        }
        private function updateChanges(_arg1:Object):void{
            dispatch(new InfoEvent(EventConstants.UPDATE_USER_DATA, null, _arg1));
        }

    }
}//package net.wooga.pets.controllers.missions 
